<template>
	<view style="background: #F8F8F8;height: 100vh;">
		<view class="user-content">
			<view class="header-top">
				<image :src="userinfo.avatar" class="header-img" mode="aspectFill"></image>
				<view class="header-info">
					<view class="t0">
						{{ userinfo.nickname }}
					</view>
					<view class="t1">
						ID：{{ userinfo.id }}
					</view>
				</view>
			</view>
			<view class="block-list">
				<view class="tit">功能服务</view>
				<view class="list-item" @click="onclickItem(1)">
					<view class="item-left">
						<image src="../../static/images/user/beifen7.png" mode=""></image>
						<text>账号与安全</text>
					</view>
					<view class="item-right">
						<image src="../../static/images/user/group3.png" mode=""></image>
					</view>
				</view>
				<view class="list-item" @click="onclickItem(2)">
					<view class="item-left">
						<image src="../../static/images/user/beifen4.png" mode=""></image>
						<text>修改密码</text>
					</view>
					<view class="item-right">
						<image src="../../static/images/user/group3.png" mode=""></image>
					</view>
				</view>
				<!-- <view class="list-item" @click="onclickItem(3)">
					<view class="item-left">
						<image src="../../static/images/user/beifen3.png" mode=""></image>
						<text>实名认证</text>
					</view>
					<view class="item-right">
						<image src="../../static/images/user/group3.png" mode=""></image>
					</view>
				</view> -->
				<!-- 	<view class="list-item" @click="onclickItem(4)">
					<view class="item-left">
						<image src="../../static/images/user/beifen2.png" mode=""></image>
						<text>清除缓存</text>
					</view>
					<view class="item-right">
						<image src="../../static/images/user/group3.png" mode=""></image>
					</view>
				</view> -->

				<view class="list-item" @click="onclickItem(5)">
					<view class="item-left">
						<image src="../../static/images/user/beifen6.png" mode=""></image>
						<text>客服电话</text>
					</view>
					<view class="item-right">
						<text>{{kf}}</text>
						<image src="../../static/images/user/group3.png" mode=""></image>
					</view>
				</view>
				<!-- <view class="list-item" @click="onclickItem(6)">
					<view class="item-left">
						<image src="../../static/images/user/beifen5.png" mode=""></image>
						<text>当前版本</text>
					</view>
					<view class="item-right">
						<image src="../../static/images/user/group3.png" mode=""></image>
					</view>
				</view> -->
			</view>
			<button size="mini" @click="loginOut" class="btn">退出账号</button>
		</view>

		<!-- 提示窗示例 -->
		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog type="success" cancelText="取消" confirmText="确认" title="" content="确认要清空缓存吗？"
				@confirm="dialogConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import api from '@/api/index2.js';
	export default {
		data() {
			return {
				title: 'Hello',
				userinfo: {},
				kf:null,
			};
		},
		onShow() {
			this.getUserInfo();
			this.getKf()
		},
		methods: {
			getKf() {
				api.sysConfig({
					site: 'sys_kefu'
				}).then(res => {
					this.kf = res.data
				})
			},
			getUserInfo() {
				api.getUserInfo().then(res => {
					let info = res.data;
					if (info) {
						uni.setStorageSync('userinfo', info);
						this.$store.commit('saveUserInfo', info)
						this.userinfo = info;
					}
				});
			},
			loginOut() {
				uni.clearStorageSync();
				this.$store.commit('saveUserInfo');
				this.$store.commit('saveToken');
				uni.reLaunch({
					url: '/pages/login/index'
				});
			},
			dialogConfirm() {
				console.log('点击确认');
			},
			onclickItem(type) {
				if (type === 1) {
					uni.navigateTo({
						url: 'accountSecurity' // 跳转到对应路径的页面
					});
				}
				if (type === 2) {
					uni.navigateTo({
						url: 'changePwd' // 跳转到对应路径的页面
					});
				}
				if (type === 3) {
					uni.navigateTo({
						url: '/pages/account/identityAuthentication' // 跳转到对应路径的页面
					});
				}
				if (type === 4) {
					this.$refs.alertDialog.open();
				}
				if (type === 5) {
					window.location.href = 'tel:' + this.kf;
				}
				if (type === 6) {}
			}
		}
	};
</script>

<style lang="scss" scoped>
	.user-content {
		background: url('../../static/images/home/home-bg.png') no-repeat;
		background-size: 100% 408rpx;
		padding-bottom: 100rpx;

		.header-top {
			display: flex;
			align-items: center;
			margin: 0 28rpx;
			padding: 30rpx 0rpx;

			.header-img {
				border-radius: 50%;
				overflow: hidden;
				width: 100rpx;
				height: 100rpx;
			}

			.header-info {
				margin-left: 20rpx;

				.t0 {
					font-family: PingFangSC, PingFang SC;
					font-weight: 600;
					font-size: 36rpx;
					color: #ffffff;
					line-height: 50rpx;
					text-align: left;
					font-style: normal;
					margin-bottom: 16rpx;
				}

				.t1 {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #ffffff;
					line-height: 40rpx;
					text-align: left;
					font-style: normal;
				}
			}
		}

		.block-list {
			background: #ffffff;
			border-radius: 28rpx;
			padding: 30rpx 20rpx;
			margin: 0 28rpx;

			.tit {
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 32rpx;
				color: #000000;
				line-height: 44rpx;
				text-align: left;
				font-style: normal;
				position: relative;
				padding-left: 20rpx;
				margin-bottom: 10rpx;

				&::before {
					position: absolute;
					content: '';
					width: 10rpx;
					height: 30rpx;
					background: #49a1fd;
					border-radius: 6rpx;
					left: 0;
					top: 8rpx;
				}
			}

			.list-item {
				display: flex;
				align-items: center;
				justify-content: space-between;
				line-height: 100rpx;
				border-bottom: 2rpx solid #e6e5e5;

				&:last-child {
					border-bottom: none;
				}

				.item-left {
					display: flex;
					align-items: center;

					uni-image {
						width: 48rpx;
						height: 48rpx;
						background: linear-gradient(180deg, #ffe26f 0%, #ff962d 100%);
						border-radius: 12rpx;
					}

					uni-text {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #222222;
						line-height: 44rpx;
						text-align: left;
						font-style: normal;
						margin-left: 20rpx;
					}
				}

				.item-right {
					uni-image {
						width: 20rpx;
						height: 20rpx;
					}

					uni-text {
						font-family: PingFangSC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #49a1fd;
						line-height: 44rpx;
						text-align: center;
						font-style: normal;
					}
				}
			}
		}

		.btn {
			background: #ffffff;
			border-radius: 44rpx;
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 34rpx;
			color: #49a1fd;
			line-height: 88rpx !important;
			text-align: right;
			font-style: normal;
			height: 88rpx;
			margin: 36rpx 28rpx;
			width: calc(100% - 56rpx);
			text-align: center;
			border: none;

			&:after {
				border: none;
			}
		}
	}
</style>